<template>
  <div>
       <!-- Form 弹窗-->

    <el-dialog
      class="alretconent tanchaungWH"
      title="修改处方"
      :visible.sync="dialogFormVisible">
      <el-form :model="form" class="">
        <el-form-item>
            <el-row>
                <el-col :span="2">处方：</el-col>
                <el-col :span="12"><el-input v-model="form.phone" autocomplete="off" class="tanchaunginput"></el-input></el-col>
            </el-row>
        
             
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitqueding">确 定</el-button>
        <el-button @click="dialogFormVisible = false">取 消</el-button>
      </div>
    </el-dialog>

    <router-link to="/index/chufang" class="styleaddBingli router-link-active">处方管理</router-link>
    <div class="bigwhite">
     <el-row :gutter="10">
      <el-col :span="4">
        <div class="grid-content bg-purple-dark">
          <el-input v-model="search" circle placeholder="请输入内容"></el-input>
        </div>
      </el-col>
      <el-col :span="5">
        <div class="grid-content bg-purple-dark">
          <el-date-picker
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            v-model="date"
            type="date"
            placeholder="选择入院时间"
          >
          </el-date-picker>
        </div>
      </el-col>
      <el-col :span="4">
      <el-select v-model="kebie" placeholder="外科" class="formwidth">
      <el-option label="外科" value="waike"></el-option>
      <el-option label="内科" value="neike"></el-option>
      <el-option label="妇科" value="fuke"></el-option>
      <el-option label="神经科" value="shenjingke"></el-option>
    </el-select>
      </el-col>
      <el-col :span="2">
        <div class="grid-content bg-purple-dark">
          <el-button
            type="primary"
            @click="submit"
            icon="el-icon-search"
            circle
          ></el-button>
        </div>
      </el-col>
    </el-row>

    <el-table
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      style="width: 100%"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection"> </el-table-column>
      <el-table-column label="住院号">
        <template slot-scope="scope">{{ scope.row.num }}</template>
      </el-table-column>
      <el-table-column label="姓名">
        <template slot-scope="scope">{{ scope.row.name }}</template>
      </el-table-column>
      <el-table-column label="性别">
        <template slot-scope="scope">{{ scope.row.sex }}</template>
      </el-table-column>
      <el-table-column label="年龄">
        <template slot-scope="scope">{{ scope.row.age }}</template>
      </el-table-column>
      <el-table-column label="病床号">
        <template slot-scope="scope">{{ scope.row.chuanghao }}</template>
      </el-table-column>
      <el-table-column label="主治医生">
        <template slot-scope="scope">{{ scope.row.doctors }}</template>
      </el-table-column>
      <el-table-column label="护士">
        <template slot-scope="scope">{{ scope.row.nusers }}</template>
      </el-table-column>
      <el-table-column label="科室">
        <template slot-scope="scope">{{ scope.row.className }}</template>
      </el-table-column>
      <el-table-column label="日期">
        <template slot-scope="scope" v-if="scope.row.blo">
          {{ scope.row.date }}
        </template>
      </el-table-column>
      <el-table-column label="处方" >
        <template slot-scope="scope" >
            <div class="hideen">{{ scope.row.chufang }}</div>
          
        </template>
      </el-table-column>
      <el-table-column label="操作" class="cellwidth">
        <template slot-scope="scope">
          <i class="el-icon-edit" @click="dit(scope.row.chufang,scope.row.chuanghao)"></i>
          <i
            class="el-icon-circle-close"
            @click="dlele(scope.row.chuanghao)"
          ></i>
        </template>
      </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
      <el-button type="danger" @click="delmany">批量删除</el-button>
      <el-button @click="toggleSelection()">取消选择</el-button>
    </div>
    </div>
  </div>
</template>

<script>

export default {
  name: "chufang",
  data() {
    return {
        index:"",
         dialogFormVisible: false,//弹窗隐藏
        date:"",
        kebie:"外科",
        phone:"",//手机号
      zhuyuanhao:"",
      bingchuanghao:"",
      search: "",
      words: "",
      form:{
          phone:""//弹窗数据
      },
      newtableDta:[],
    tableData: [
        // {
        //   date: "2016-05-03",
        //   name: "王小虎1",
        //   address: "上海市普陀区金沙江路 1518 弄",
        // }
        {
          num: "01",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3028,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "未住院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "02",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3029,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已出院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "03",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3030,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "预住院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "04",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3031,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "未住院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: false,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "05",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3032,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已住院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
        {
          num: "06",
          name: "小明",
          sex: "男",
          age: 50,
          className: "外科",
          province: "河南",
          chuanghao: 3033,
          doctors: "赵医师",
          nusers: "乔护士",
          status: "已住院",
          chufang:"5%葡萄糖,阿司匹林分散片，注射用巴韦林，摇头丸，鸦片，溜冰，大金链子",
          blo: true,
          city: "郑州",
          zdtype: "骨折",
          date: "2020-12-8",
        },
      ],
      multipleSelection: [],
       currentPage3: 5,
    };
  },
//     mounted() {
//   },
  methods: {
       dlele(num) {
      // var newarr=""
      for (let i = 0; i < this.tableData.length; i++) {
        if (this.tableData[i].chuanghao == num) {
          this.tableData.splice(i,1)
          return
        }
      }
    },
       submit() {
      console.log(this.search, this.date);
    },
    //修改处方
        submitqueding() {
            for (let i = 0; i < this.tableData.length; i++) {
              if(this.tableData[i].chuanghao==this.index){
                this.tableData[i].chufang=this.form.phone
                this.dialogFormVisible = false;
                return;
              }
                
            }
            // this.tableData.chufang=this.form.phone
        // console.log(this.tableData.chufang)
      
    },
    handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        console.log(`当前页: ${val}`);
      },
     delmany() {
      console.log(this.multipleSelection);
      for (let i = 0; i < this.tableData.length; i++) {
        for (let j = 0; j < this.multipleSelection.length; j++) {
          if (this.tableData[i] == this.multipleSelection[j]) {
            this.tableData.splice(i, 1);
          }
        }
      }
    },
       toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
      handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    dit(i,index) {
      //编辑
    //   console.log(i);
    //   console.log(index);
      this.index=index
      this. dialogFormVisible=true
      this.form.phone=i
    },
  },
  computed: {
  },
};
</script>

<style lang="scss" scoped>
.router-link-active {
  background: #16dcb8;
  padding: 14px 35px;
  margin-left: 20px;

  border-top-left-radius: 30px;
  border-bottom-right-radius: 30px;
  color: white;
  display: inline-block;
  background-image: linear-gradient(to right, #2dc6e1, #14dfba);
}
.el-icon-edit {
  padding-right: 20px;
  font-size: 18px;
  color: #16dcb8;
}
.el-icon-circle-close {
  font-size: 18px;
  color: #16dcb8;
}
.hideen{   
overflow:hidden !important; //超出的文本隐藏
text-overflow:ellipsis !important; //溢出用省略号显示
white-space:nowrap !important;
}
.tanchaunginput /deep/ input{
    height: 200px;
        width: 400px;
    overflow:hidden !important; //超出的文本隐藏
text-overflow:ellipsis !important; //溢出用省略号显示
white-space:nowrap !important;
}
.tanchaungWH /deep/ .el-dialog{
       width: 610px;
}
</style>